<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%--
  Created by IntelliJ IDEA.
  User: zzc
  Date: 2018/9/10
  Time: 16:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>企业行业排名上传</title>
    <style>
        .upload{
            display: inline-block;
            margin: 0 5px;
            width: 60px;
            height: 34px;
            background: #ff7772;
            color: #fff;
            border-radius: 5px;
            font-size: 12px;
            text-align: center;
            line-height: 34px;
            cursor: pointer;
            border: none;
        }
    </style>
</head>
<body>
    <div class="upload-download">
        <input type="file" name="file" id="file" accept=".xlsx">
        <button class="upload" data-id="import">上传</button>
    </div>



    <script src="<s:url value="/assets/js/jquery.js"></s:url>"></script>
    <script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>

    <script>
        $(function () {
            //    上传
            $(".upload").click(function() {
                var fileval = $(this).prev().val();
                console.log(fileval);
                var fileId = $(this).prev().attr("id");
                console.log(fileId);
                if (fileval == null || fileval == "") {
                    alert("未选择任何文件");
                    return;
                }

                $("#dialog").show();
                $.ajaxFileUpload({
                    type : "post",
                    fileElementId : fileId,
                    secureuri : false,
                    dataType : 'json',
                    url : "/data/importdata/import",
                    async : true,
                    success : function(data) {
                        if(data.code == "200"){
                            alert("数据上传成功");
                        }else{
                            alert("文件上传失败 ！！请联系管理员");
                        }
                    }
                });

            });
        })
    </script>
</body>
</html>
